Skip to main content

Dialog 弹出框

弹出模态框,常用于消息提示、消息确认,或在当前页面内完成特定的交互操作。属于交互型「弹层组件」,包括触发元素和弹出内容。


组件代码​

<template>
<View class="button" @click="onShow"> // 触发元素
结算
<van-dialog
v-model="dialogVisible"
title="弹窗标题"
theme="default"
confirm-button-text="确认"
:show-cancel-button="true"
cancel-button-text="取消"
message="弹窗内容"
></van-dialog> // Dialog 弹出框组件代码
</View>
</template>

<script
export default {
components: {},
data() {
return {
dialogVisible: false,
};
},

methods: {
onShow() {
this.dialogVisible = true;
},
},
};
</script>

组件配置​


Dialog 弹出框包含多种类型,通过交互配置可直接实现消息提示、消息确认、圆角按钮风格、使用 Dialog 组件等类型。

操作流程​

  1. 选中触发元素,在右侧交互设置面板,选择 Dialog 弹出框;
  2. 设置交互配置项。

使用 Dialog 组件​

如果需要在 Dialog 内嵌入组件或其他自定义内容,可以选择「关联业务组件」,关联的业务组件将插入 van-dialog 标签内部,作为其子元素。

组件代码​

<template>
<span class="button" @click="onShow">
首页
<van-dialog
v-model="dialogVisible"
width="407px"
title="弹窗标题"
theme="default"
confirm-button-text="确认"
:show-cancel-button="true"
cancel-button-text="取消"
>
<DialogContent></DialogContent> // 引入自定义弹框内容
</van-dialog>
</span>
</template>

<script>
import DialogContent from '../../components/dialogContent/dialogContent.vue';

export default {
components: { DialogContent },
data() {
return {
dialogVisible: false,
};
},

methods: {
onShow() {
this.dialogVisible = true;
},
},
};
</script>